# 创建动态库 (SHARED)
add_library(mylib2 SHARED
    src/mylib2.cpp
)

# 设置动态库版本 (可选)
set_target_properties(mylib2 PROPERTIES
    VERSION 1.0.0
    SOVERSION 1
)

# 设置安装后的 RPATH
# set_target_properties(mylib PROPERTIES
#     INSTALL_RPATH "$ORIGIN/../lib"
#     BUILD_WITH_INSTALL_RPATH TRUE
# )

# 包含目录
target_include_directories(mylib2 PUBLIC 
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

# 选项
# option(BUILD_SHARED_LIBS "Build shared library." ON)

# 定义导出宏 (Windows 需要)
if(WIN32)
    target_compile_definitions(mylib2 PRIVATE MYLIB2_EXPORTS)
    target_compile_definitions(mylib2 INTERFACE MYLIB2_IMPORTS)
endif()

# 安装配置
install(TARGETS mylib2
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin  # Windows DLL 需要
)

install(DIRECTORY include/ DESTINATION include)